package com.edgardeng.consumer;

import com.edgardeng.entity.Merchant;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.PropertySource;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

/**
 * 定义消费者
 */
@Component
@PropertySource("classpath:rabbitmq.properties")
@RabbitListener(queues = "${com.edgardeng.queue.first}", containerFactory = "rabbitListenerContainerFactory")
public class FirstConsumer {

    @RabbitHandler
    public void process(@Payload Merchant m) {
        // 生产者发送了一个对象，接收者通过Payload  获取
        System.out.println("[FirstConsumer] process receive:" + m.toString() );
    }
}
